let logger = require('pomelo-logger').getLogger(__filename);

module.exports = function(app) {
    return new Remote(app);
};

let Remote = function(app) {
    this.app = app;
};

Remote.prototype.notifyPlayerOnline = function(msg, callback) {
    let niuniuTableService = this.app.get("niuniuTableService");
    callback(niuniuTableService.notifyPlayerOnline(msg.frontendId, msg.sessionId, msg.uid));
};

Remote.prototype.notifyPlayerOffline = function (msg, callback) {
    let niuniuTableService = this.app.get("niuniuTableService");
    niuniuTableService.notifyPlayerOffline(msg.frontendId, msg.sessionId);
    callback();
};

Remote.prototype.notifyPlayerBalanceChange = function (msg, callback) {
    let niuniuTableService = this.app.get("niuniuTableService");
    niuniuTableService.notifyPlayerBalanceChange(msg.frontendId, msg.sessionId);
    callback();
};

Remote.prototype.getNiuniuTables = function (msg, callback) {
    let niuniuTableService = this.app.get("niuniuTableService");
    let niuniuTables = niuniuTableService.getVisibleYuanBaoTables();
    if(!!niuniuTables) {
        callback({
            resultCode: 0,
            message: "ok",
            tables: niuniuTables
        });
    }
    else {
        callback({
            resultCode: 404,
            message: "玩家信息为空"
        });
    }
};
